//
//  WLVisitorTableViewController.swift
//  weibo
//
//  Created by 刁 海瑞 on 16/8/9.
//  Copyright © 2016年 毋磊. All rights reserved.
//

import UIKit

class WLVisitorTableViewController: UITableViewController {
//    记录是否登记
    let isLogin: Bool = WLUserAccountViewModel.sharedUserAccount.isLogin
    
    var visitor: WLVistorView?
    
    override func loadView() {
        
        if isLogin {
            
            super.loadView()
        }else{
            
            visitor = WLVistorView()
            
            visitor?.loginClosure = { [weak self] in
                
                self?.reqeustOAuthVC()
                
            }
            
            view = visitor
            
            setNavUI()
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    private func setNavUI() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", tarfet: self, action: "registerAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", tarfet: self, action: "loginAction")
        
        
    }
    @objc private func registerAction(){
        print("注册")
        reqeustOAuthVC()
    }
    
    @objc private func loginAction() {
        print("登录")
        reqeustOAuthVC()
    }
    
    //  登录第三方的函数
    private func reqeustOAuthVC() {
        
        let oAuthVC = WLOAuthViewController()
        let nav = UINavigationController(rootViewController: oAuthVC)
        
        presentViewController(nav, animated: true, completion: nil)
    }

}
